package servlet;

import domain.Emp;
import service.UpEmpServiceImp;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpEmpServlet extends HttpServlet {
    private UpEmpServiceImp upEmpServiceImp =new UpEmpServiceImp();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求的参数
        String sid = request.getParameter("id");
        int id=Integer.parseInt(sid);
        //获取到员工数据
        Emp emp = upEmpServiceImp.getEmp(id);
        request.setAttribute("emp",emp);

        //跳转到修改的页面
        request.getRequestDispatcher("/pages/empupdate.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
    }
}
